import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import router, { staticRoutes } from './router'
import { store, key } from './store'
// import API from '@/api'
import 'normalize.css/normalize.css'
import App from './App.vue'

import 'dayjs/locale/zh-cn'
import locale from 'element-plus/lib/locale/lang/zh-cn'

import '@/styles/index.scss'

const create = () => {
  createApp(App)
    .use(store, key)
    .use(router)
    .use(ElementPlus, { locale })
    // .use(API) // 本地 api 全局挂载
    .mount('#app')
}

window.addEventListener('pywebviewready', function () {
  console.log('pywebview is ready')
  window.console.warn = window.console.log
  window.console.error = window.console.log
  // 初始化基础路由
  store.dispatch('permission/initRouters', staticRoutes)
  // 初始化用户文件数据
  store.dispatch('permission/initUsers')
  create()
})
